var sObj = {
  level1: {
    btn1: 1,
    btn2: 2,
    btn3: 3,
    btn4: 4,
    btn5: 5,
    btn6: 6,
    btn7: 7,
    btn8: 8,
    btn9: 9,
  },
  level2: {
    btn1: 1,
    btn2: 2,
    btn3: 3,
    btn4: 4,
    btn5: 5,
    btn6: 6,
    btn7: 7,
    btn8: 8,
    btn9: 9,
  }
}

//直接使用全局变量
function getBtn() {
  let b1 = sObj.level1.btn1;
  let b3 = sObj.level1.btn3;
  let b5 = sObj.level1.btn5;
  let b7 = sObj.level1.btn7;
  let b9 = sObj.level1.btn9;
}

//缓存全局变量(优)
function getBtn() {
  let obj = sObj;
  let b1 = obj.btn1;
  let b3 = obj.btn3;
  let b5 = obj.btn5;
  let b7 = obj.btn7;
  let b9 = obj.btn9;
}